package com.scedu.luckeymoney;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Service

public class LuckymoneyService {
    @Autowired
    LuckymoneyRepository luckymoneyRepository;
    /*
      事务 指的是数据库事务
      扣库存 > 创建订单
     */
    @Transactional
    public  void createtwo(){
        //第一个红包
        Luckymoney luckymoney=new Luckymoney();
        luckymoney.setProducer("添添");
        luckymoney.setMoeny(new BigDecimal("520"));
        luckymoneyRepository.save(luckymoney);

        //第二个红包
        Luckymoney luckymoney2=new Luckymoney();
        luckymoney2.setProducer("添添");
        luckymoney2.setMoeny(new BigDecimal("1314"));
        luckymoneyRepository.save(luckymoney2);
    }
}
